<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddColumnEntityCodeInTaskTable extends AbstractMigration
{
    public function up()
    {
        $this->table('task')
            ->addColumn('entity_code', 'string', [
                'limit' => 128,
                'default' => '',
                'null' => false,
                'comment' => '所属实体code'
            ])
            ->addIndex(['project_id','entity_code','step_category_id'], ['name' => 'idx_project_id_entity_code', 'type' => 'normal'])
            ->save();

    }

    public function down()
    {
        $this->table('task')
            ->removeColumn('entity_code')
            ->removeIndex('idx_project_id_entity_code')
            ->save();
    }
}
